<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      style="height: 100%;padding: 0;margin: 0;"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <title>省管理</title>
    <meta charset="UTF-8"/>
    <link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/default/easyui.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/icon.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/easyui/demo/demo.css}"/>
    <script type="text/javascript" th:src="@{/easyui/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/easyui/jquery.easyui.min.js}"></script>
    <script type="text/javascript" th:src="@{/easyui/locale/easyui-lang-zh_CN.js}"></script>
</head>
<body style="height: 100%;width: 100%;padding: 0;margin: 0;">
<table id="tt" title="省列表" style="width:100%;height:100%;"
       data-options="toolbar:toolbar,rownumbers:true,
       singleSelect:true,pagination:true,url:'/t/province/list',method:'post'">
    <thead>
    <tr>
        <th field="id" checkbox="true"></th>
        <th field="code" width="45%">编码</th>
        <th field="name" width="50%">名称</th>
    </tr>
    </thead>
</table>


<script type="text/javascript">
    $(function () {
        var pager = $('#tt').datagrid().datagrid('getPager');
    })
    var toolbar = [];
</script>

<script sec:authorize="hasRole('SYS_ROLE_ADD')">
    toolbar.push({
        text: '初始化省市区数据',
        iconCls: 'icon-reload',
        handler: function () {
            $.messager.confirm('提示', '确定要删除这条记录吗?', function (res) {
                if (res) {
                    $.post("/t/province/init/all", {}, function (result) {
                        $.messager.alert("提示","操作成功");
                        reloads();
                    });
                }
            });
        }
    });
</script>

<script type="text/javascript">
    toolbar.push('-', {
        text: '刷新',
        iconCls: 'icon-reload',
        handler: reloads
    });
    function reloads() {
        $('#tt').datagrid('reload');//刷新
    }
</script>
</body>
</html>